package com.yugao.fintech.antelope.auth.service.impl;

import com.yugao.fintech.antelope.auth.model.mq.LoginLogMQ;
import com.yugao.fintech.antelope.auth.service.AuthMqService;
import com.yugao.fintech.antelope.base.model.module.mq.OAuth2ClientMQ;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AuthMqServiceImpl implements AuthMqService {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Override
    public void send(LoginLogMQ mq) {
        rabbitTemplate.convertAndSend(LoginLogMQ.EXCHANGE, LoginLogMQ.KEY, mq.toMessage());
    }

    @Override
    public void deleteClientAuthority(String clientId) {
        rabbitTemplate.convertAndSend(OAuth2ClientMQ.EXCHANGE, "", OAuth2ClientMQ.build(clientId).toMessage());
    }
}
